﻿#region Usings

using System.Windows;
using System.Windows.Media;
using Box2DX.Collision;

#endregion

namespace SilverBox.Physics
{
    public interface IShapeProvider
    {
        FrameworkElement BodyShape { get; }
    }

    public interface IShapeGeometry
    {
        ShapeDef GetShapeDefinition(SimulatorContext context);
    }

    public interface IBodyMover
    {
        double ElementAngle { get; set; }
        Point ElementPosition { get; set; }
    }

    public class BodyMover : IBodyMover
    {
        private FrameworkElement element;

        private RotateTransform rotation = new RotateTransform();
        private TranslateTransform translation = new TranslateTransform();

        public BodyMover(FrameworkElement element)
        {
            this.element = element;

            var transform = new TransformGroup();
            transform.Children.Add(rotation);
            transform.Children.Add(translation);

            this.element.RenderTransformOrigin = new Point(.5, .5);
            this.element.RenderTransform = transform;
        }

        #region IBodyMover Members

        public double ElementAngle
        {
            get { return rotation.Angle; }
            set { rotation.Angle = value; }
        }

        public Point ElementPosition
        {
            get { return new Point(translation.X, translation.Y); }
            set
            {
                translation.X = value.X;
                translation.Y = value.Y;
            }
        }

        #endregion
    }
}